package module.service.impl;

import common.bean.SearchParameter;
import module.dao.SysRoleDao;
import module.model.SysRoleModel;
import module.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SysRoleServiceImpl implements SysRoleService {
    @Autowired
    SysRoleDao sysRoleDao;

    @Transactional
    public List<SysRoleModel> finRoleByResourceId(Long resourceId) {
        SearchParameter searchParameter = new SearchParameter();
        searchParameter.addParam("resourceId", resourceId);
        return getSysRoleModelRoleResourceListBySearchParameter(searchParameter);
    }
    @Transactional
    public List<SysRoleModel> findSysUserRole(Long objId) {
        SearchParameter searchParameter = new SearchParameter();
        searchParameter.addParam("objId", objId);
        return getSysRoleModelRoleDispatcherListBySearchParameter(searchParameter);
    }

    public List<SysRoleModel> getSysRoleModelRoleResourceListBySearchParameter(SearchParameter searchParameter) {
        return sysRoleDao.getSysRoleModelRoleResourceListBySearchParameter(searchParameter);
    }

    public List<SysRoleModel> getSysRoleModelRoleDispatcherListBySearchParameter(SearchParameter searchParameter) {
        return sysRoleDao.getSysRoleModelRoleDispatcherListBySearchParameter(searchParameter);
    }
}
